<?php
namespace app\index\controller;
use think\Controller;
use think\Request;
use think\Db;
use app\index\model\Users;
use app\index\model\Personals;
/*群聊*/
class Crowd extends Common
{
	/*创建群*/
	public function custom(){
     $nonce='abcb123';
      $ctime=time();
      $csum=sha1('572faf2b1b76'.$nonce.$ctime);
      $headers = array();
      $headers[] = 'AppKey: 98b90dd621eef6bfc37b9a2917a96776';
      $headers[] = 'Nonce: '.$nonce;
      $headers[] = 'application/x-www-form-urlencoded;charset=utf-8;';
      $headers[] = 'CurTime: '.$ctime;
      $headers[] = 'CheckSum: '.$csum;
      $members=json_encode(['2']);
      $post_data=['tname'=>'单身酷玩1','owner'=>'2','members'=>$members,'msg'=>'加群啦','magree'=>'0','joinmode'=>'0'];
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
      curl_setopt($ch, CURLOPT_URL,'http://api.netease.im/nimserver/team/create.action');
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
      $output = curl_exec($ch);
       print_r($output);die;
  }
   //拉人进群
  public function holding(){
     $nonce='abcb123';
      $ctime=time();
      $csum=sha1('572faf2b1b76'.$nonce.$ctime);
      $headers = array();
      $headers[] = 'AppKey: 98b90dd621eef6bfc37b9a2917a96776';
      $headers[] = 'Nonce: '.$nonce;
      $headers[] = 'application/x-www-form-urlencoded;charset=utf-8;';
      $headers[] = 'CurTime: '.$ctime;
      $headers[] = 'CheckSum: '.$csum;
      $members=json_encode(['5']);//邀请的人
      $post_data=['tid'=>'527845272','owner'=>'2','members'=>$members,'magree'=>'0','msg'=>'加群啦'];
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
      curl_setopt($ch, CURLOPT_URL,'http://api.netease.im/nimserver/team/add.action');
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
      $output = curl_exec($ch);
      print_r($output);die;
  }
  //踢人出群
  public function kick(){
     $nonce='abcb123';
      $ctime=time();
      $csum=sha1('572faf2b1b76'.$nonce.$ctime);
      $headers = array();
      $headers[] = 'AppKey: 98b90dd621eef6bfc37b9a2917a96776';
      $headers[] = 'Nonce: '.$nonce;
      $headers[] = 'application/x-www-form-urlencoded;charset=utf-8;';
      $headers[] = 'CurTime: '.$ctime;
      $headers[] = 'CheckSum: '.$csum;
      $members=json_encode(['8']);//邀请的人
      $post_data=['tid'=>'519899452','owner'=>'1','members'=>$members];
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
      curl_setopt($ch, CURLOPT_URL,'http://api.netease.im/nimserver/team/kick.action');
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
      $output = curl_exec($ch);
      print_r($output);die;
  }
  //解散群
  public function remove(){
    $nonce='abcb123';
      $ctime=time();
      $csum=sha1('572faf2b1b76'.$nonce.$ctime);
      $headers = array();
      $headers[] = 'AppKey: 98b90dd621eef6bfc37b9a2917a96776';
      $headers[] = 'Nonce: '.$nonce;
      $headers[] = 'application/x-www-form-urlencoded;charset=utf-8;';
      $headers[] = 'CurTime: '.$ctime;
      $headers[] = 'CheckSum: '.$csum;
      $members=json_encode(['8']);//邀请的人
      $post_data=['tid'=>'519899452','owner'=>'1'];
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
      curl_setopt($ch, CURLOPT_URL,'http://api.netease.im/nimserver/team/remove.action');
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
      $output = curl_exec($ch);
      print_r($output);die;
  }
  //消息功能
   public function news(){
    $nonce='abcb123';
      $ctime=time();
      $csum=sha1('572faf2b1b76'.$nonce.$ctime);
      $headers = array();
      $headers[] = 'AppKey: 98b90dd621eef6bfc37b9a2917a96776';
      $headers[] = 'Nonce: '.$nonce;
      $headers[] = 'application/x-www-form-urlencoded;charset=utf-8;';
      $headers[] = 'CurTime: '.$ctime;
      $headers[] = 'CheckSum: '.$csum;
      //$body=json_encode('按刷电脑刷电脑');//邀请的人
     // print_r($body);die;
     // $members=json_encode(['8']);//邀请的人
      $post_data=['from'=>'5','ope'=>'1','to'=>'527845272','type'=>'0','body'=>'{"msg":"收到没说下"}'];
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
      curl_setopt($ch, CURLOPT_URL,'http://api.netease.im/nimserver/msg/sendMsg.action');
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
      $output = curl_exec($ch);
      print_r($output);die;
  }
    //更改名片
  //  public function news(){
  //   $nonce='abcb123';
  //     $ctime=time();
  //     $csum=sha1('572faf2b1b76'.$nonce.$ctime);
  //     $headers = array();
  //     $headers[] = 'AppKey: 98b90dd621eef6bfc37b9a2917a96776';
  //     $headers[] = 'Nonce: '.$nonce;
  //     $headers[] = 'application/x-www-form-urlencoded;charset=utf-8;';
  //     $headers[] = 'CurTime: '.$ctime;
  //     $headers[] = 'CheckSum: '.$csum;
  //     //$body=json_encode('按刷电脑刷电脑');//邀请的人
  //    // print_r($body);die;
  //    // $members=json_encode(['8']);//邀请的人
  //     $post_data=['accid'=>'1','name'=>'梦幻','icon'=>'http://p9bdh7i0p.bkt.clouddn.com/5a174201805301251454358.jpg'];
  //     $ch = curl_init();
  //     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  //     curl_setopt($ch, CURLOPT_URL,'http://api.netease.im/nimserver/user/updateUinfo.action');
  //     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  //     curl_setopt($ch, CURLOPT_POST, 1);
  //     curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  //     $output = curl_exec($ch);
  //     print_r($output);die;
  // }
  //获取名片
  //  public function news(){
  //   $nonce='abcb123';
  //     $ctime=time();
  //     $csum=sha1('572faf2b1b76'.$nonce.$ctime);
  //     $headers = array();
  //     $headers[] = 'AppKey: 98b90dd621eef6bfc37b9a2917a96776';
  //     $headers[] = 'Nonce: '.$nonce;
  //     $headers[] = 'application/x-www-form-urlencoded;charset=utf-8;';
  //     $headers[] = 'CurTime: '.$ctime;
  //     $headers[] = 'CheckSum: '.$csum;
  //      $accids=json_encode(['1']);
  //     //$body=json_encode('按刷电脑刷电脑');//邀请的人
  //    // print_r($body);die;
  //    // $members=json_encode(['8']);//邀请的人
  //     $post_data=['accids'=>$accids];
  //     $ch = curl_init();
  //     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  //     curl_setopt($ch, CURLOPT_URL,'http://api.netease.im/nimserver/user/getUinfos.action');
  //     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  //     curl_setopt($ch, CURLOPT_POST, 1);
  //     curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  //     $output = curl_exec($ch);
  //     print_r($output);die;
  // }
   //更改名片
  //  public function news(){
  //   $nonce='abcb123';
  //     $ctime=time();
  //     $csum=sha1('572faf2b1b76'.$nonce.$ctime);
  //     $headers = array();
  //     $headers[] = 'AppKey: 98b90dd621eef6bfc37b9a2917a96776';
  //     $headers[] = 'Nonce: '.$nonce;
  //     $headers[] = 'application/x-www-form-urlencoded;charset=utf-8;';
  //     $headers[] = 'CurTime: '.$ctime;
  //     $headers[] = 'CheckSum: '.$csum;
  //     //$body=json_encode('按刷电脑刷电脑');//邀请的人
  //    // print_r($body);die;
  //    // $members=json_encode(['8']);//邀请的人
  //     $post_data=['accid'=>'1','ex'=>'领队'];
  //     $ch = curl_init();
  //     curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  //     curl_setopt($ch, CURLOPT_URL,'http://api.netease.im/nimserver/user/updateUinfo.action');
  //     curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
  //     curl_setopt($ch, CURLOPT_POST, 1);
  //     curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
  //     $output = curl_exec($ch);
  //     print_r($output);die;
  // }
  //获取群组信息
    public function queryDetail(){
        $nonce='abcb123';
      $ctime=time();
      $csum=sha1('572faf2b1b76'.$nonce.$ctime);
      $headers = array();
      $headers[] = 'AppKey: 98b90dd621eef6bfc37b9a2917a96776';
      $headers[] = 'Nonce: '.$nonce;
      $headers[] = 'application/x-www-form-urlencoded;charset=utf-8;';
      $headers[] = 'CurTime: '.$ctime;
      $headers[] = 'CheckSum: '.$csum;
      $post_data=['tid'=>'527845272'];
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
      curl_setopt($ch, CURLOPT_URL,'https://api.netease.im/nimserver/team/queryDetail.action');
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
      curl_setopt($ch, CURLOPT_POST, 1);
      curl_setopt($ch, CURLOPT_POSTFIELDS, $post_data);
      $output = curl_exec($ch);
      print_r($output);die;
    }
}